package com.lsz.word;

import java.util.ArrayList;
import java.util.List;


/**
 * 用来生成所有与输入参数word的"编辑距离"为1的词
 * @author lsz m
 *
 */
public class Edits1 {
	private String word;
	private List<String> splits;//将word依次按照每一位分割成前后两半。
	private List<String> beletes;//依次删除word的每一位后、所形成的所有新词。
	private List<String> transposes;//依次交换word的邻近两位，所形成的所有新词。
	private List<String> replaces;//将word的每一位依次替换成其他25个字母，所形成的所有新词。
	private List<String> inserts;//在word的邻近两位之间依次插入一个字母，所形成的所有新词。
	public Edits1(String word){
		this.word = word;
	}
	public String getWord() {
		return word;
	}
	public void setWord(String word) {
		this.word = word;
	}
	public List<String> getSplits() {
		int mid = 1;
		splits = new ArrayList<String>();
		for(;mid<word.length();mid++){
			String tmp1 = word.substring(0,mid);
			String tmp2 = word.substring(mid,word.length());
			
			splits.add(tmp1);
			splits.add(tmp2);
		}
		return splits;
	}
	public List<String> getBeletes() {
		char c[] = word.toCharArray();
		beletes = new ArrayList<String>();
		for(int i=0;i<word.length();i++){
			String tmp = "";
			for(int j=0;j<word.length();j++){
				if(i == j)continue;
				tmp += c[j];
			}
			beletes.add(tmp);
			
		}
		return beletes;
	}
	public List<String> getTransposes() {
		transposes = new ArrayList<String>();
	
		char tmpc = 0;
		String tmps = "";
		for(int i =0;i<word.length()-1;i++){
			char  c[] = word.toCharArray();
			tmpc = c[i];
			c[i] = c[i+1];
			c[i+1] = tmpc;
			tmps = new String(c);
			transposes.add(tmps);
		}
		return transposes;
	}
	public List<String> getReplaces() {
		return replaces;
	}
	public List<String> getInserts() {
		return inserts;
	}
	
	
	
}

